part of '../repository.dart';

const _kAmDialectValue = 'am';
const _kBrDialectValue = 'br';

class _DialectDto extends Equatable {
  const _DialectDto._internal({
    required this.dialectString,
  });

  final String dialectString;

  @override
  List<Object?> get props {
    return [
      dialectString,
    ];
  }

  factory _DialectDto.fromString(String dialectString) {
    return _DialectDto._internal(
      dialectString: dialectString,
    );
  }

  factory _DialectDto.fromEntity(Dialect dialect) {
    final dialectString = switch (dialect) {
      Dialect.am => _kAmDialectValue,
      Dialect.br => _kBrDialectValue,
    };

    return _DialectDto._internal(
      dialectString: dialectString,
    );
  }

  @override
  String toString() {
    return dialectString;
  }

  Dialect toEntity() {
    return switch (dialectString) {
      _kAmDialectValue => Dialect.am,
      _kBrDialectValue => Dialect.br,
      _ => throw UnimplementedError(),
    };
  }
}
